package com.fattyCorps.game.controller;

import com.fattyCorps.game.obj.msg.SRet;
import com.fattyCorps.game.obj.msg.client.rank.CGetRankListMsg;
import com.fattyCorps.game.obj.msg.server.rank.SGetRankListMsg;
import com.fattyCorps.game.service.RankService;
import com.fattyCorps.game.service.rank.RankElem;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/player")
public class RankController {

    @Autowired
    RankService rankService;

    // 获取排行榜
    @PostMapping("/getRank")
    public SRet getRank(HttpServletRequest request, @RequestBody CGetRankListMsg cGetRankListMsg){
        List<RankElem> rankList = rankService.getRankList(cGetRankListMsg.getType());
        SGetRankListMsg msg = new SGetRankListMsg();
        msg.setRankElemList(rankList);
        return SRet.success(msg);
    }
}
